﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;

namespace TileSetConverter
{
    public class TileSetTile
    {
        public Bitmap bitmap;
        public byte[] header = new byte[29];

        public byte id;
        public Int32 width;
        public Int32 height;
        public Int32 xOffset;
        public Int32 yOffset;
        public Int32 imageHandle;
        public Int32 paletteHandle;
        public byte bitsPerPixel;
        public byte frameWidth;
        public byte frameHeight;
        public byte alignment;

        public TileSetTile(Bitmap p1, byte[] p2)
        {
            bitmap = p1;
            header = p2;

            id = p2[0];
            width = BitConverter.ToInt32(p2, 1);
            height = BitConverter.ToInt32(p2, 5);
            xOffset = BitConverter.ToInt32(p2, 9);
            yOffset = BitConverter.ToInt32(p2, 13);
            imageHandle = BitConverter.ToInt32(p2, 17);
            paletteHandle = BitConverter.ToInt32(p2, 21);
            bitsPerPixel = p2[25];
            frameWidth = p2[26];
            frameHeight = p2[27];
            alignment = p2[28];
        }
    }
}
